package com;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

@RestController
public class HelloSpringBoot {

    @RequestMapping("hello")
    public String hello(HttpServletRequest request) {
        ServletContext context = request.getServletContext();
        WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);
        for (String name : ctx.getBeanDefinitionNames()
        ) {
            System.out.println(name);
        }
        return "Hello SpringBoot!";
    }


}
